package com.pudding.listener.read;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.pudding.entity.StockEntity;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author Pudding
 * @Date 2025/3/19 11:55
 * 自定义简单数据读取监听器
 */
@Slf4j
public class SimpleReadListener implements ReadListener<StockEntity> {


    /**
     * 每读取一条数据，就会调用invoke方法
     *
     * @param stockEntity
     * @param analysisContext
     */
    @Override
    public void invoke(StockEntity stockEntity, AnalysisContext analysisContext) {
        log.info("读取到一条数据：{}", stockEntity);
    }

    /**
     * 读取完成之后，会调用doAfterAllAnalysed方法，做一些释放资源、数据清理的操纵
     *
     * @param analysisContext
     */
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        log.info("读取完成");
    }
}
